//
//  OSUnFairLockDemo.m
//  iOSLock
//
//  Created by 崔博 on 2018/7/24.
//  Copyright © 2018年 崔博. All rights reserved.
//

#import "OSUnFairLockDemo.h"
#import <os/lock.h>
@interface OSUnFairLockDemo()
@property (nonatomic, assign) os_unfair_lock moenyLock;
@property (nonatomic, assign) os_unfair_lock ticketLock;
@end
@implementation OSUnFairLockDemo

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.moenyLock = OS_UNFAIR_LOCK_INIT;
        self.ticketLock = OS_UNFAIR_LOCK_INIT;
    }
    return self;
}


- (void)__saleTickets
{
    os_unfair_lock_lock(&_ticketLock);
    [super __saleTickets];
    os_unfair_lock_unlock(&_ticketLock);
}
- (void)__saveMoney
{
    os_unfair_lock_lock(&_moenyLock);
    [super __saveMoney];
    os_unfair_lock_unlock(&_moenyLock);
}
- (void)__drawMoney
{
    os_unfair_lock_lock(&_moenyLock);
    [super __drawMoney];
    os_unfair_lock_unlock(&_moenyLock);
}
@end
